public class Solution374 {

    int guess;

    int guess(int num){
        if (num>guess){
            return -1;
        }else if (num<guess){
            return 1;
        }else{
            return 0;
        }
    }

    public int guessNumber(int n) {
        int l=1,r=n;
        while (l<=r){
            long t=(0L+l+r)/2;
            int mid=(int) t;
            if (guess(mid)==-1){
                r=mid-1;
            }else if (guess(mid)==1){
                l=mid+1;
            }else {
                return mid;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        Solution374 solution374=new Solution374();
        solution374.guess=6;
        System.out.println(solution374.guessNumber(100));
    }
}
